﻿namespace PlugNT.Database
{
    using System;
    using System.Collections.Generic;
    using System.Text;

    public class JoinInfo
    {
        public string AndJoinWhere;
        public string ColumnsString;
        private List<string> iandWhere;
        public string JoinTableString;

        public JoinInfo()
        {
            this.iandWhere = null;
        }

        public JoinInfo(string _JoinTableString, string _ColumnsString, string _AndJoinWhere)
        {
            this.iandWhere = null;
            this.JoinTableString = _JoinTableString;
            this.ColumnsString = _ColumnsString;
            this.AndJoinWhere = _AndJoinWhere;
        }

        public void AndWhere(string where)
        {
            if (this.iandWhere == null)
            {
                this.iandWhere = new List<string>();
            }
            this.iandWhere.Add(where);
        }

        public string AndWhereToJoinString()
        {
            StringBuilder builder = new StringBuilder();
            if (this.iandWhere != null)
            {
                foreach (string str in this.iandWhere)
                {
                    builder.Append(" and a." + str + " ");
                }
            }
            return builder.ToString();
        }

        public string AndWhereToString()
        {
            StringBuilder builder = new StringBuilder();
            if (this.iandWhere != null)
            {
                foreach (string str in this.iandWhere)
                {
                    builder.Append(" and " + str + " ");
                }
            }
            return builder.ToString();
        }
    }
}

